<?php
//创建server对象，监听 9001端口
$server = new swoole_server("127.0.0.1", 9001);
//监听链接进入事件
$server->on('connect', function($server, $fd){
    echo "客户端:链接.\n";
});

$server->on('receive', function($server, $fd, $from_id, $data){
    $server->send($fd, 'Server:' . $data);
});

$server->on('close', function($server, $fd){
    echo "client:close.\n";
});

$server->start();